package com.ushio.commonmodule.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class SwaggerStartupLogger implements ApplicationListener<ApplicationReadyEvent> {

    @Value("${server.port:8080}")
    private String port;

    @Value("${server.servlet.context-path:}")
    private String contextPath;

    @Value("${springdoc.swagger-ui.path:/swagger-ui.html}")
    private String swaggerPath;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        System.out.println("--------------------------------------------------------");
        String baseUrl = "http://localhost:" + port + contextPath;
        System.out.println("🎯 应用已启动成功！");
        System.out.println("🌐 服务地址: " + baseUrl);
        System.out.println("🌐 Swagger 文档地址: " + baseUrl + swaggerPath);
        System.out.println("--------------------------------------------------------");
    }
}

